<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue 3 模板语法</title>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>
<body>
    <div id="app">
        <button @click="increment">增加</button>
        <p>计数：{{ count }}</p>
        <p>计数：{{ state.counter }}</p>
        
    </div>

    <script>
        const { createApp, ref, reactive,computed } = Vue;

        createApp({
            setup() {
                const count = ref(0);
                const state = reactive({ counter: 0 });

                // 定义一个函数来更新count
                const increment = () => {
                    count.value++;
                    state.counter++;
                };

                // 返回响应式数据和函数
                return { count, state,increment };
            }

        }).mount('#app');
    </script>
</body>
</html>
